package com.bill99.rpc.config.spring.schema;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

import com.bill99.rpc.application.ApplicationBean;

/**
 * @author sheng.zhang
 */
public class ApplicationBeanDefinationParser extends
		AbstractRpcBeanDefinationParser {

	private final Logger logger = LoggerFactory.getLogger(getClass());

	@Override
	protected Class<?> getBeanClass(Element element) {
		return ApplicationBean.class;
	}

	@Override
	protected void doParse(Element element, ParserContext parserContext,
			BeanDefinitionBuilder builder) {
		String name = element.getAttribute("name");
		if (name != null && name.trim().length() > 0)
			builder.addPropertyValue("name", name);
		else {
			parserContext.getReaderContext().error(
					"Attribute[name] is required.", element);
		}
	}

}
